import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import {
    registerApplication,
    start
} from "single-spa"

Vue.config.productionTip = false
async function loadScript(url) {
    return new Promise((resolve, reject) => {
        const script = document.createElement('script');
        script.src = url;
        script.onload = resolve;
        script.onerror = reject
        document.head.appendChild(script)
    })
}

window.singleSpaVue
registerApplication(
    'myVueApp',
    async() => {
        await loadScript(" http://192.168.0.108:8081/js/chunk-vendors.js")
        await loadScript(" http://192.168.0.108:8081/js/app.js")
        console.log(window.singleSpaVue);
        return window.singleSpaVue
    },
    location => location.pathname.startsWith('/vue') //何时加载应用，在/vue的时候
)

start()
new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')

// npm install single - spa